<%@ page contentType="text/html;charset=UTF-8" %>
<!DOCTYPE html>
<html lang="en">
<head>
<%@include file="../common/includeBaseSet.jsp" %>
<%@include file="../../common/includeSystemSet.jsp" %>
<%@include file="../../common/operation_forbid.jsp" %>
<script type="text/javascript">
		$(function(){
			getList();
		});
		
		function add(title,url){
			JY.Model.edit("noticeType_div",title,function(){
				 if(JY.Validate.form("noticeTypeForm")){
					 var that =$(this);
					 JY.Ajax.doRequest("noticeTypeForm",url,null,function(data){
						layer.msg(data.resMsg);
						getList();
						that.dialog("close"); 
					 }); 
				 }	
			});
		}
		function edit(id){
			JY.Ajax.doRequest("baseForm",jypath +'/estate/dictionary/view?id='+id,null,function(data){
				add("修改类别",jypath+"/estate/dictionary/edit?id="+id);
				$("input[name='dictionaryName']").val(data.obj.dictionaryName);
			});
		}
		
		function del(id){
			JY.Ajax.doRequest("baseForm",jypath +'/estate/dictionary/delete?id='+id,null,function(data){
				layer.msg(data.resMsg);
				getList();
			});
		}
		
	function getList(){
		JY.Model.loading();
		JY.Ajax.doRequest("baseForm",jypath +'/estate/dictionary/list?dictionaryType=${type}',null,function(data){
			 $("#baseTable tbody").empty();
			 var page=data.obj;
			 //数据集合
        	 var results=page.rows;
        	 //分页数据
         	 var pageNum=page.pageNumber,pageSize=page.pageSize,totalRecord=page.total;
         	 var permitBtn=[
         	       		  {name:"修改",btnFun:"edit",icon:"icon-edit color-blue"},
         	       		  {name:"删除",btnFun:"del",icon:"icon-remove-sign color-red"},
         	       		 ];
        	 var html="";
        	 if(results!=null&&results.length>0){
        		 var leng=(pageNum-1)*pageSize;//计算序号
        		 for(var i = 0;i<results.length;i++){
        			 var l=results[i];
        			 html+="<tr><td class='center'>"+JY.Object.notEmpty(l.dictionaryName)+"</td>";
        			 html+=JY.Tags.setFunction(l.id,permitBtn);
        			 html+="</tr>";
        		 }
        		 $("#baseTable tbody").append(html);
        		 JY.Page.setPage("baseForm","pageing",pageSize,pageNum,totalRecord,"getList");
        	 }else{
        			html+="<tr><td colspan='10' class='center'>没有相关数据</td></tr>";
            		$("#baseTable tbody").append(html);
            		$("#pageing ul").empty();//清空分页
        	 }
        	 JY.Model.loadingClose();
		});
	}
</script>
<title>公告设置</title>
</head>
<body>
<div class="page-content">
		<div class="row-fluid">	
			<div class="col-xs-12">
			<form id="baseForm" class="form-inline" method="POST" onsubmit="return false;">
			<div class="widget-main">													
				<button type="button" id="system_role_add" onclick="add('添加类别','${jypath}/system/resources/saveDictionary')" class="btn btn-primary btn-sm"><span class="glyphicon glyphicon-plus">新增</span></button> 
			</div>				
				<input type='hidden' class='pageNum' name='pageNum' value='1'/>
				<input type='hidden' class='pageSize'  name='pageSize' value='5'/>
			</form>
 <table id="baseTable" class="table table-striped table-bordered table-hover" >
						<thead>
							<tr>
								<!-- <th style="width:1%" class="center">
									<label><input type="checkbox" class="ace" ><span class="lbl"></span></label>	
								</th> -->
								<th  class="center">类别</th>
								<th  class="center">操作</th>
							</tr>
						</thead>
						<tbody></tbody>
	</table>
						<div class="row">
						<div class="col-sm-5">
							<!--设置分页位置-->
							<div id="pageing" class="dataTables_paginate paging_bootstrap">
								<ul class="pagination"></ul>
							</div>
						</div>
		</div>
			</div>
				</div>
					</div>
						<%@include file="noticeType_from.jsp" %>
</body>
</html>